package datalookin.adapter2;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.whu.zj.MyApplication;
import com.whu.zj.R;

import java.util.ArrayList;
import java.util.List;

import datalookin.dto.WaterPlantDto;
import datalookin.dto2.StationDataDto;

/**
 * 历史水厂信息
 * Created by Administrator on 2016/3/14.
 */
public class HistoryStationAdapter extends BaseAdapter {

    List<StationDataDto> stationDataDtos = new ArrayList<StationDataDto>();

    public void setStationDataDtos(List<StationDataDto> stationDataDtos) {
        this.stationDataDtos = stationDataDtos;
    }

    @Override
    public int getCount() {
        return stationDataDtos.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null)
        {
            viewHolder = new ViewHolder();
;
            convertView = View.inflate(MyApplication.share(),R.layout.item_historyplant,null);
            viewHolder.tv_station = (TextView) convertView.findViewById(R.id.id_tv_station);
            viewHolder.tv_time = (TextView) convertView.findViewById(R.id.id_tv_time);
            viewHolder.tv_value = (TextView) convertView.findViewById(R.id.id_tv_value);
            convertView.setTag(viewHolder);
        }
        else
        {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        StationDataDto waterPlantDto = stationDataDtos.get(position);
        viewHolder.tv_station.setText(waterPlantDto.getStationnum());
        viewHolder.tv_time.setText(waterPlantDto.getTime().substring(0,10)+ "\n" +waterPlantDto.getTime().substring(11));
        viewHolder.tv_value.setText(waterPlantDto.getValue());
        return convertView;
    }

    public static class ViewHolder
    {
        public TextView tv_station;
        public TextView tv_time;
        public TextView tv_value;
    }
}
